def is_vowel(c):
    return c in 'aeiouAEIOU'


def longest_flawedvowel_substr_len(m, s):
    for i in range(len(s)):
        if is_vowel(s[i]):
            break
        i += 1
    else:
        return 0

    sum_q = 0
    flaw = 0
    result = 0
    for j in range(i, len(s)):
        sum_q += 1
        if not is_vowel(s[j]):
            flaw += 1
            continue
        while flaw > m:
            sum_q -= 1
            if not is_vowel(s[i]):
                flaw -= 1
            i += 1
        while i < len(s) and not is_vowel(s[i]):
            sum_q -= 1
            flaw -= 1
            i += 1
        if flaw == m:
            result = max(result, sum_q)
    return result

print(longest_flawedvowel_substr_len(0, 'bab'))
# print(longest_flawedvowel_substr_len(0, 'asdbuiodevauufgh'))
# print(longest_flawedvowel_substr_len(2, 'aeueo'))
# print(longest_flawedvowel_substr_len(2, 'ppppppppp'))
# print(longest_flawedvowel_substr_len(2, 'pppppppapdipxxxxxxxxxxxxxx'))

def brutal_solve(m, s):
    n = len(s)
    if m == 0:
        result = 0
        count = 0
        for c in s:
            if is_vowel(c):
                count += 1
                result = max(result, count)
            else:
                count = 0
        return result

    result = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if is_vowel(s[i]) and is_vowel(s[j]):
                if len([c for c in s[i:j+1] if not is_vowel(c)]) == m:
                    result = max(result, j-i+1)
    return result


# print(longest_flawedvowel_substr_len(2, 'ababba'))

def test():
    for _ in range(10000):
        import random
        m = random.randint(0, 10)
        n = random.randint(0, 10)
        s = ''.join(random.choices('ab', k=n))
        res1 = longest_flawedvowel_substr_len(m, s)
        res2 = brutal_solve(m, s)
        if res1 != res2:
            print(m, s, res1, res2)
test()

#
# if __name__ == "__main__":
#     flaw = int(input().strip())
#     input_string = input().strip()
#     result = longest_flawedvowel_substr_len(flaw, input_string)
#     print(result)
#
